home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / Scanning Generic LaserWriter / Generic LaserWriter.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-20  |  3.5 KB  |  140 lines  |  [TEXT/MPS ]

  1. /*-----------------------------------------------------------------------------
  2.  
  3.     Generic LaserWriter.h
  4.     
  5.         Header file for Generic LaserWriter.c.
  6.         
  7.         6/18/94 - dmh - Created while adding 'scan' handling support.
  8.         8/28/94 - dmh - Finalized for SDK.
  9.     
  10.     © 1991-1994 Apple Computer Inc.
  11.     
  12. -----------------------------------------------------------------------------*/
  13.  
  14. #include <ToolUtils.h>
  15. #include <Types.h>
  16. #include <Errors.h>
  17. #include <Resources.h>
  18. #include <GXPrinterDrivers.h>
  19. #include <GXMessages.h>
  20. #include <GXExceptions.h>
  21.  
  22.  
  23.     // Predefined goodies.
  24.  
  25. #define kCreator    'scL1'
  26.  
  27.  
  28.     // 'scan' entry types.
  29.     
  30. enum {
  31.     SimpleScan = 0,
  32.     UserNameScan,
  33.     DocumentNameScan,
  34.     PrinterNameScan,
  35.     NilPtrScan
  36. };
  37.  
  38.  
  39.     // 'scan' offset types.
  40.  
  41. enum {
  42.     SimpleOffset = 0,
  43.     SameAsPreviousOffset,
  44.     ReturnedOffset,
  45.     SimpleRepeat = 16,
  46.     SameAsPreviousRepeat,
  47.     ReturnedRepeat
  48. };
  49.  
  50.  
  51.     // 'scan' action types.
  52.  
  53. enum {
  54.     NoAction = 0,
  55.     SimpleAction
  56. };
  57.  
  58.  
  59.     // 'scan' error types. (For SimpleAction entries.)
  60.  
  61. enum {
  62.     Normal = 0,
  63.     NonFatalError,
  64.     FatalError
  65. };
  66.  
  67.  
  68.     // Values passed to our ScanText routine to indicate which 'scan' to use.
  69.  
  70. enum {
  71.     kScanStatusTextType,
  72.     kScanPrinterTextType
  73. };
  74.  
  75.  
  76.     // IDs of the two 'scan' resources we use to pre-scan the data.
  77.  
  78. #define kStatusTextScanResID    (gxPostscriptScanningID +6)
  79. #define kPrinterTextScanResID    (gxPostscriptScanningID +7)
  80.  
  81.  
  82.     // ID of the 'stat' resource we use for alerts and such.
  83.  
  84. #define kPrescanStatResID        (gxPrintingDriverBaseID +10)
  85.  
  86.  
  87.     // Index into our 'stat' resource for the "printerReady" entry.
  88.  
  89. #define kPrinterIsReadyIndex    1
  90.  
  91.  
  92.     // Our "instance context" global data structure.
  93.  
  94. typedef struct DriverInstanceGlobals {
  95.         gxStatusRecord    *printStatus;    // status record for GXAlertTheUser.
  96.         short            statusLevel;    // last alert level: Normal, NonFatalError or FatalError.
  97.         short            statusIndex;    // last index into our 'stat' resource passed to GXAlertTheUser.
  98.         Str31            userName;        // user name from the currently printing job.
  99.         Str31            appName;        // application name from the currently printing job.
  100.         Str31            documentName;    // document name from the currently printing job.
  101.         Str31            printerName;    // output printer name from the currently printing job.
  102. } DriverInstanceGlobals, **DriverInstanceGlobalsHdl;
  103.  
  104.  
  105.     // Our "class context" global data structure.
  106.  
  107. typedef struct DriverClassGlobals {
  108.         long            ownerCount;        // owner count for our data.
  109.         Handle            statusScanHdl;    // 'scan' handle for gxPostScriptScanStatusText.
  110.         Handle            printerScanHdl;    // 'scan' handle for gxPostScriptScanPrinterText.
  111. } DriverClassGlobals, **DriverClassGlobalsHdl;
  112.  
  113.  
  114.     // Function prototypes.
  115.  
  116. OSErr    DriverOpenConnection(void);
  117. void    DriverCleanupOpenConnection(void);
  118. OSErr    DriverCloseConnection(void);
  119. OSErr    SetUpInstanceContextData(void);
  120. void    StoreInstanceContextStrings(DriverInstanceGlobalsHdl instanceGlobals);
  121. void    DisposeInstanceContextData(void);
  122. OSErr    SetUpClassContextData(void);
  123. void    DisposeClassContextData(void);
  124. OSErr    DriverPostScriptScanPrinterText(Handle textHdl);
  125. OSErr    DriverPostScriptScanStatusText(Handle textHdl);
  126. OSErr    ScanText(Handle textHdl, char scanType, Boolean *alertedUser);
  127. OSErr    HandleScanning(Handle textHdl, Handle scanHdl, Boolean *alertedUser);
  128.  
  129. OSErr    DecodeScanEntry(short **scanPtr,
  130.                         char **str1Ptr, long *str1Len,
  131.                         char **str2Ptr, long *str2Len,
  132.                         short *offsetType, short *actionType,
  133.                         short *statusLevel, short *statusIndex);
  134.  
  135. Boolean    MungeTheText(short offsetType, Handle textHdl,
  136.                      void *ptr1, long len1,
  137.                      void *ptr2, long len2);
  138.  
  139. OSErr    SetAlertStatus(short statResourceID, short statResourceIndex);
  140.